﻿using System;
using Castle.Windsor;
using Castle.Windsor.Installer;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RomanNumeralKata.Tests
{
    /// <summary>
    ///     Used as a base so that we can access the contianer, although, we really shouldn't need it
    /// </summary>
    [TestClass]
    public class RomanNumeralKataIocTestBase : IDisposable
    {
        private WindsorContainer _container;
        private bool _disposed;

        public RomanNumeralKataIocTestBase()
        {
            BootStrap();
        }

        public WindsorContainer Container
        {
            get { return _container; }
        }

        public void Dispose()
        {
            if (_disposed) return;
            _container.Dispose();
            _disposed = true;
        }

        private void BootStrap()
        {
            _container = new WindsorContainer();
            // _container.Install(FromAssembly.InThisApplication());
            // call installers, which tightly bind implementations which could be good
            // or bad depending..if we are instantiating tests that hit file io/web/etc
            // then we are stuck to mock them
            // better to build container per test scenarios/situation and use mocks
        }
    }
}